package com.sskj.wallet.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.MD5Util;
import com.sskj.lib.BaseHttpConfig;
import com.sskj.lib.bean.CurrentTypeBean;
import com.sskj.lib.bean.ShiftBean;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.wallet.ui.activity.StateTransferActivity;

import java.util.List;


/**
 * @author Hey
 * Create at  2019/07/16
 */
public class StateTransferPresenter extends BasePresenter<StateTransferActivity> {


    public void getCoins() {
        httpService.getCoins()
                .tag(this)
                .execute(new JsonCallBack<HttpData<List<String>>>() {
                    @Override
                    public void onSuccess(Response<HttpData<List<String>>> response) {
                        List<String> data = response.body().getData();
                        mView.getCoinsOK(data);
                    }
                });
    }

    public void getCoinUsable(String coinName, String type) {
        httpService.getCoinUsable(coinName, type)
                .tag(this)
                .execute(new JsonCallBack<HttpData<ShiftBean>>() {
                    @Override
                    public void onSuccess(Response<HttpData<ShiftBean>> response) {
                        mView.getCoinUsableOK(response.body().getData());
                    }
                });
    }

    public void stateTransfer(String coin, String mobile, String amount, String pwd) {
        httpService.stateTransfer(coin, mobile, amount, MD5Util.getFiveMd5Value(pwd))
                .tag(this)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        if (response.body().status == BaseHttpConfig.OK) {
                            mView.transferOK();
                        }
                    }
                });

    }
}
